// import axios from 'axios'
import {getData as axios} from '@/axios/index.js'

export default {
  //更新菜单请求菜单列表(默认树形结构)
  updatamenu({commit},payload ={istree: 1}) {
    axios({
      method: 'get',
      url: '/api/menulist',
      params: payload
    }).then(res => {
      console.log(res.list,'menuList---------');
      commit('updatamenu', res.list)
    })
  },
  //更新 角色 请求角色列表
  updaterole({commit},payload) {
    axios({
      method: 'get',
      url: '/api/rolelist',
      params: payload
    }).then(res => {
      console.log(res.list, 'rolelist--------')
      if (res.list) {
        commit('updaterole', res.list)
      }
    })
  },
  //请求管理员列表
  updateuser({commit}, payload) {
    axios({
      method: 'get',
      url: '/api/userlist',
      params: payload
    }).then(res => {
      if (res.list) {
        console.log(res.list, 'userList---------')
        commit('updateuser', res.list)
      }
    })
  },
  //更新 分类
  updatecategory({commit}, payload = {}) {
    payload.istree = 1
    //请求管理员列表
    axios({
      method: 'get',
      url: '/api/catelist',
      params: payload
    }).then(res => {
      if (res.list) {
        console.log(res.list,'categoryList-----');
        commit('updatecategory', res.list)
      }
    })
  },
  //商品规格 列表
  updatespecs({commit}, payload = {size: 2, page: 1}) {
    axios({
      method: 'get',
      url: '/api/specslist',
      params: payload
    }).then(res => {
      if (res.list) {
        console.log(res.list,'specsList--------')
        commit('updatespecs', res.list)
      }
    })
  },
  //商品规格 列表
  updatagoods({commit}, payload = {size: 2, page: 1}) {
    axios({
      method: 'get',
      url: '/api/goodslist',
      params: payload
    }).then(res => {
      console.log(res.list, 'updatagoods------')
      if (res.list) {
        commit('updatagoods', res.list)
      }
    })
  },
  //限时秒杀列表
  updateseck({commit}, payload) {
    axios({
      method: 'get',
      url: '/api/secklist',
      params: payload
    }).then(res => {
      if (res.list) {
        console.log(res.list, 'seckList---------')
        commit('updateseck', res.list)
      }
    })
  },
  //限时秒杀列表
  updatabanner({commit}, payload) {
    axios({
      method: 'get',
      url: '/api/bannerlist',
      params: payload
    }).then(res => {
      if (res.list) {
        console.log(res.list, 'bannerList---------')
        commit('updatabanner', res.list)
      }
    })
  },
  //请求 会员 列表
  updatamember({commit}, payload) {
    axios({
      method: 'get',
      url: '/api/memberlist',
      params: payload
    }).then(res => {
      if (res.list) {
        console.log(res.list, 'memberList---------')
        commit('updatamember', res.list)
      }
    })
  },
}
